class ButGame extends egret.Sprite{
	private botom = RES.getRes("botom_png");//底部
	public redBut = RES.getRes("redbut_png");//红色按钮
	public redEnd = RES.getRes("redend_png");//红色按钮按下
	public yelBut = RES.getRes("yelbut_png");//黄色按钮
	public yelEnd = RES.getRes("yelend_png");//黄色按钮按下
	public grenBut = RES.getRes("grenbut_png");//绿色按钮
	public grenEnd = RES.getRes("grenend_png");//绿色按钮按下
	public ButRed:egret.Bitmap;//红色
	public ButGreen:egret.Bitmap;//绿色
	public ButYel:egret.Bitmap;//黄色
	public constructor() {
		super();
		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.init,this);

	}
	private init() {
		//底部
		var botObj = new egret.Bitmap(); 
		botObj.texture = this.botom;
		botObj.width = botObj.texture.textureWidth / 2;
		botObj.height = botObj.texture.textureHeight / 2;
		botObj.x = (this.stage.stageWidth - botObj.width) / 2;
		botObj.y=this.stage.stageHeight - botObj.height;
		this.addChild(botObj);
		
		// 红色按钮
		this.ButRed= new egret.Bitmap(); 
		this.ButRed.texture = this.redBut;
		this.ButRed.width = this.ButRed.texture.textureWidth / 2.5;
		this.ButRed.height = this.ButRed.texture.textureHeight / 2.5;
		this.ButRed.x = botObj.x - botObj.width * 0.28;
		this.ButRed.y= botObj.y - this.ButRed.height / 2;
		this.addChild(this.ButRed);

		// 绿色按钮
		this.ButGreen= new egret.Bitmap(); 
		this.ButGreen.texture = this.grenBut;
		this.ButGreen.width = this.ButGreen.texture.textureWidth / 2.5;
		this.ButGreen.height = this.ButGreen.texture.textureHeight / 2.5;
		this.ButGreen.x = botObj.x + botObj.width * ( 1 - 0.15) ;
		this.ButGreen.y= botObj.y - this.ButGreen.height / 2;
		this.addChild(this.ButGreen);

		// 黄色按钮
		this.ButYel= new egret.Bitmap(); 
		this.ButYel.texture = this.yelBut;
		this.ButYel.width = this.ButYel.texture.textureWidth / 2.5;
		this.ButYel.height = this.ButYel.texture.textureHeight / 2.5;
		this.ButYel.x = (this.stage.stageWidth - this.ButYel.width) / 2 ;
		this.ButYel.y= this.ButGreen.y - this.ButYel.height / 2;
		this.addChild(this.ButYel);

		// 开启点击事件
		this.ButRed.touchEnabled = true;
		this.ButGreen.touchEnabled = true;
		this.ButYel.touchEnabled = true;
		this.ButRed.addEventListener(egret.TouchEvent.TOUCH_BEGIN,()=>{
			this.ButRed.texture = this.redEnd;
		},this);//鼠标按下
		this.ButRed.addEventListener(egret.TouchEvent.TOUCH_END,()=>{
			this.ButRed.texture = this.redBut;
		},this);//鼠标松开


		this.ButGreen.addEventListener(egret.TouchEvent.TOUCH_BEGIN,()=>{
			this.ButGreen.texture = this.grenEnd;
		},this);//鼠标按下
		this.ButGreen.addEventListener(egret.TouchEvent.TOUCH_END,()=>{
			this.ButGreen.texture = this.grenBut;
		},this);//鼠标松开
		
		
		this.ButYel.addEventListener(egret.TouchEvent.TOUCH_BEGIN,()=>{
			this.ButYel.texture = this.yelEnd;
		},this);//鼠标按下
		this.ButYel.addEventListener(egret.TouchEvent.TOUCH_END,()=>{
			this.ButYel.texture = this.yelBut;
		},this);//鼠标松开
	}
}